#include<stdio.h>

int main()
{
	int n,x,s;
	while (scanf("%d",&n)==1)
	{
		if (n<0||n>10000)
		{
			printf("Input Error\n");
			continue;
		}
		if (n==0)
		{
			printf("End Of Input\n");
			continue;
		}
		while (1)
		{
			x=n;
			s=0;
			while (x!=0)
			{
				s=10*s+x%10;
				x/=10;
			}
			if (s==n)
			{
				printf("%d\n",n);
				break;
			}
			n++;
		}
		
	}
	return 0;
}
